package com.example.zyfirst.comtroller;

import com.example.zyfirst.Service.UserService;
import com.example.zyfirst.entity.User;
import io.swagger.annotations.Api;

import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "User测试接口")
@RestController
@RequestMapping("/user/")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation(value = "listallAPI")
    @RequestMapping(value = "/listall",method = {RequestMethod.POST})
    public String listAll(){
        List<User> list=userService.list();
        return list.toString();
    }

    @ApiOperation(value = "insertAPI")
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public String insert(User user){

        Boolean save=userService.save(user);
        if (save){
            return "成功";
        }
        return "失败";
    }

}
